// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   NodeSystemDaoImpl.java

package com.hfstu.ifs.dataaccess.dao.impl;

import com.hfstu.framework.core.orm.Page;
import com.hfstu.framework.core.orm.PageRequest;
import com.hfstu.framework.core.orm.hibernate.PageDAOSpringTemplate;
import com.hfstu.framework.util.StringUtil;
import com.hfstu.ifs.dataaccess.dao.INodeSystemDao;
import com.hfstu.ifs.model.NodeSystem;
import java.util.*;
import org.hibernate.criterion.*;

public class NodeSystemDaoImpl extends PageDAOSpringTemplate
	implements INodeSystemDao
{

	public NodeSystemDaoImpl()
	{
	}

	private DetachedCriteria defaultCriteria()
	{
		DetachedCriteria criteria = DetachedCriteria.forClass(getPersistentClass(), "nodeSystem");
		return criteria;
	}

	public List findListByCondition(Map filterPropertyMap, Map sortValueMap)
	{
		DetachedCriteria criteria = defaultCriteria();
		if (filterPropertyMap != null && !filterPropertyMap.isEmpty())
		{
			Object value = null;
			Set keys = filterPropertyMap.keySet();
			for (Iterator iterator = keys.iterator(); iterator.hasNext();)
			{
				String key = (String)iterator.next();
				value = filterPropertyMap.get(key);
				if (key.equals("nodeSystem.name") && !StringUtil.isNullOrEmpty((String)value))
					criteria.add(Restrictions.like(key, (new StringBuilder("%")).append(value).append("%").toString()));
				if (key.equals("nodeSystem.codes"))
					criteria.add(Restrictions.in("nodeSystem.code", (Object[])value));
				value = null;
			}

		}
		if (sortValueMap != null && !sortValueMap.isEmpty())
		{
			Set keys = sortValueMap.keySet();
			for (Iterator iterator1 = keys.iterator(); iterator1.hasNext();)
			{
				String key = (String)iterator1.next();
				String value = (String)sortValueMap.get(key);
				if (!StringUtil.isNullOrEmpty(key) && !StringUtil.isNullOrEmpty(value))
				{
					if (value.equalsIgnoreCase("desc"))
						criteria.addOrder(Order.desc(key));
					if (value.equalsIgnoreCase("asc"))
						criteria.addOrder(Order.asc(key));
				}
			}

		}
		return super.findListByCriteria(criteria);
	}

	public Page findPageByCondition(PageRequest pageRequest, Map filterPropertyMap, Map sortValueMap)
	{
		StringBuilder hql = new StringBuilder();
		hql.append(" select nodeSystem from NodeSystem nodeSystem");
		return super.findPageByCondition(pageRequest, hql.toString(), filterPropertyMap, sortValueMap);
	}

	public NodeSystem getByCode(String code)
	{
		Criterion c = Restrictions.eq("code", code);
		return (NodeSystem)super.findUnique(new Criterion[] {
			c
		});
	}

	public List getByCodes(List codes)
	{
		Criterion c = Restrictions.in("code", codes);
		return super.findListByCriteria(new Criterion[] {
			c
		});
	}
}
